package com.le.tester.book.effectivejava3rdchinese.secondReading.l37;

import java.util.EnumMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * createTime：2024-09-18 13:37
 * description：使用enumMap代替序列索引
 */
public class Plant {
    enum LifeCycle {ANNUAL, PERENNIAL, BIENNIAL}

    final String name;

    final LifeCycle lifeCycle;

    public Plant(String name, LifeCycle lifeCycle) {
        this.name = name;
        this.lifeCycle = lifeCycle;
    }

    @Override
    public String toString() {
        return "Plant{" +
                "name='" + name + '\'' +
                ", lifeCycle=" + lifeCycle +
                '}';
    }

    Map<Plant.LifeCycle, Set<Plant>> platByLifeCycle = new EnumMap<>(Plant.LifeCycle.class);

    public void f() {

        for (Plant.LifeCycle lc : Plant.LifeCycle.values()) {
            platByLifeCycle.put(lc, new HashSet<>());
        }

//        for (Plant p : garden) {
//
//        }
    }

}
